package com.ideaaedi.zoo.example.springboot.dynamic.ds.shardingsphere.config;

import com.ideaaedi.commonspring.transaction.DefaultManualTransactionSupport;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;


/**
 * 指定事务管理器 DefaultManualTransactionSupport
 *
 * @author <font size = "20" color = "#3CAA3C"><a href="https://gitee.com/JustryDeng">JustryDeng</a></font> <img src="https://gitee.com/JustryDeng/shared-files/raw/master/JustryDeng/avatar.jpg" />
 * @since 2022/3/25 10:33
 */
@Slf4j
@Configuration
public class ManualTransactionConfig {
    
    @Autowired
    private DataSourceTransactionManager defaultTransactionManager;
    
    @PostConstruct
    public void initTransactionManager() {
        DefaultManualTransactionSupport.initTransactionManager(defaultTransactionManager);
    }
}
